Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add integ tests for OS metrics(cpu, page fault) #252

Merged
merged 2 commits into from
Jan 12, 2021
Merged

Conversation

rguo-aws
Copy link
Contributor

@rguo-aws rguo-aws commented Dec 1, 2020

Fixes #, if available:

Description of changes:
Add integ tests for OS metrics(cpu, page fault)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rguo-aws rguo-aws requested review from yu-sun-77, yojs and ktkrg December 1, 2020 23:52
public void checkCPUUtilization() throws Exception {
//read metric from local node
List<JsonResponseNode> responseNodeList =
readMetric(PERFORMANCE_ANALYZER_BASE_ENDPOINT + "/metrics/?metrics=CPU_Utilization&agg=sum");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we create path as constant variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this endpoint is only referenced once here. and I have defined a const var for the common path that can be used by other endpoint. Do we still need to define a seperate static var here ?

Assert.assertEquals(OSMetrics.CPU_UTILIZATION.toString(), responseData.getField(0).getName());
Assert.assertEquals(Constants.DOUBLE, responseData.getField(0).getType());
Assert.assertEquals(1, responseData.getRecordSize());
Assert.assertTrue(responseData.getRecordAsDouble(0, OSMetrics.CPU_UTILIZATION.toString()) > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any upper bound we need to check for CPU usage as well other than greater than 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. yes, I think we can check upper bound here for cpu usage. Will add it

Assert.assertEquals(OSMetrics.PAGING_MAJ_FLT_RATE.toString(), responseData.getField(0).getName());
Assert.assertEquals(Constants.DOUBLE, responseData.getField(0).getType());
Assert.assertEquals(1, responseData.getRecordSize());
Assert.assertTrue(responseData.getRecordAsDouble(0, OSMetrics.PAGING_MAJ_FLT_RATE.toString()) >= 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't the value of PAGING_MAJ_FLT_RATE always be >=0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it will always be >= 0 if the page metrics are read correctly. unfortunately this is the only sanity check we can do for this metric because the occurance of page fault is out of our control and it would be hard to write a IT to force OS to trigger page fault

Assert.assertEquals(OSMetrics.PAGING_MIN_FLT_RATE.toString(), responseData.getField(0).getName());
Assert.assertEquals(Constants.DOUBLE, responseData.getField(0).getType());
Assert.assertEquals(1, responseData.getRecordSize());
Assert.assertTrue(responseData.getRecordAsDouble(0, OSMetrics.PAGING_MIN_FLT_RATE.toString()) >= 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't the value of PAGING_MIN_FLT_RATE always be >=0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

return records[index][i];
}
}
throw new IllegalArgumentException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in which scenario this IllegalArgumentException will be thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this exception will be thrown if the record retrieved from PA does not have the "field" we look for

Copy link
Contributor

@yu-sun-77 yu-sun-77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, overall LGTM

Copy link
Contributor

@ktkrg ktkrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just one nit around javadoc.

import com.amazon.opendistro.elasticsearch.performanceanalyzer.integ_test.json.JsonResponseData;
import com.google.gson.annotations.SerializedName;

public class JsonResponseNode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we add javadoc describing how the various JsonResponse* classes are nested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. added comments on top of each JsonResponse* class

@codecov
Copy link

codecov bot commented Jan 11, 2021

Codecov Report

Merging #252 (737aade) into master (73c2e62) will increase coverage by 71.16%.
The diff coverage is 80.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master     #252       +/-   ##
=============================================
+ Coverage      9.96%   81.12%   +71.16%     
- Complexity       50      319      +269     
=============================================
  Files            39       39               
  Lines          2018     1770      -248     
  Branches        150      134       -16     
=============================================
+ Hits            201     1436     +1235     
+ Misses         1809      232     -1577     
- Partials          8      102       +94     
Impacted Files Coverage Δ Complexity Δ
...performanceanalyzer/PerformanceAnalyzerPlugin.java 80.21% <ø> (+80.21%) 11.00 <0.00> (+11.00)
...alyzer/collectors/CacheConfigMetricsCollector.java 82.85% <ø> (+82.85%) 7.00 <0.00> (+7.00)
...zer/collectors/FaultDetectionMetricsCollector.java 0.00% <ø> (-17.65%) 0.00 <0.00> (-4.00)
...analyzer/collectors/MasterServiceEventMetrics.java 71.31% <ø> (+71.31%) 15.00 <0.00> (+15.00)
...r/collectors/MasterThrottlingMetricsCollector.java 0.00% <ø> (-20.76%) 0.00 <0.00> (-4.00)
...llectors/NodeStatsFixedShardsMetricsCollector.java 90.98% <ø> (+90.98%) 10.00 <0.00> (+10.00)
...rmanceanalyzer/collectors/ShardStateCollector.java 79.68% <ø> (+64.06%) 9.00 <0.00> (+5.00)
...nalyzer/collectors/ThreadPoolMetricsCollector.java 89.55% <ø> (+89.55%) 10.00 <0.00> (+10.00)
...analyzer/config/PerformanceAnalyzerController.java 70.27% <ø> (+69.36%) 23.00 <0.00> (+22.00)
...config/PerformanceAnalyzerClusterConfigAction.java 84.61% <ø> (+84.61%) 9.00 <0.00> (+9.00)
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73c2e62...5475bd8. Read the comment docs.

@rguo-aws rguo-aws merged commit d141dc1 into master Jan 12, 2021
@rguo-aws rguo-aws deleted the rguo-integ-test branch January 12, 2021 18:38
yujias0706 added a commit that referenced this pull request Jan 15, 2021
commit d141dc1
Author: Ruizhen Guo <[email protected]>
Date:   Tue Jan 12 10:36:50 2021 -0800

    Add integ tests for OS metrics(cpu, page fault) (#252)

    * Add integ tests for OS metrics(cpu, page fault)

commit 8c04a7e
Author: Yu Sun <[email protected]>
Date:   Fri Jan 8 10:14:30 2021 -0800

    Improve Test Coverage to 81% (#258)

    * pending tests to be tested on linuxOS only

    * add UT for MasterServiceEventMetricsTests

    * add UT for PerformanceAnalyzerSearchListenerTests

    * move linuxOS check to @BeforeClass

    * add UT for MasterServiceMetricsTests

    * add UT for NodeStatsSettingHandlerTests

    * add UT for WhoAmI package

    * remove unused PA reader tests

    * clean metricQueue before running every test

    * pending tests to be tested on linuxOS only

    * add UT for MasterServiceEventMetricsTests

    * add UT for PerformanceAnalyzerSearchListenerTests

    * move linuxOS check to @BeforeClass

    * add UT for MasterServiceMetricsTests

    * add UT for NodeStatsSettingHandlerTests

    * add UT for WhoAmI package

    * remove unused PA reader tests

    * clean metricQueue before running every test

    * add UT for PerformanceAnalyzerActionFilterTests

    * add UT for PerformanceAnalyzerActionListenerTests

    * add UT for PerformanceAnalyzerControllerTests

    * add UT for EventLogFileHandlerTests

    * exclude test for ClusterSettingsManager.java

    * code review changes

    Co-authored-by: Yu Sun <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants